package com.ityuxin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ityuxin.common.PageResult;
import com.ityuxin.dao.ServiceOrderMapper;
import com.ityuxin.domain.Orders;
import com.ityuxin.service.ServiceOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yyh
 * @Description:
 * @Date:Create：in 2021/4/3 16:18
 * @Modified By：
 */
@Service
public class ServiceOrderImpl implements ServiceOrder {


    @Autowired
    private ServiceOrderMapper serviceOrderMapper;


    @Override
    public void deleteById(Integer id) {
        serviceOrderMapper.deleteById(id);
    }



    @Override
    public void addserviceitem(Orders order) {
        serviceOrderMapper.addserviceitem(order);
    }


    @Override
    public void updateserviceitem(Orders order) {
        serviceOrderMapper.updateserviceitem(order);
    }


    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        //定义页面大小和当前页码
        PageHelper.startPage(currentPage,pageSize);

        //条件查询
        List<Orders> list =  serviceOrderMapper.findAll();

        //将数据进行包装
        PageInfo pageInfo  = new PageInfo<Orders>(list);

        return  new PageResult(pageInfo.getTotal(),pageInfo.getList());
    }


    @Override
    public Orders findById(Integer id) {
        return serviceOrderMapper.findById(id);
    }
}
